HAL GPIO io operation functions migration

This section provides information about the HAL GPIO io operation functions migration.

HAL GPIO functions

HAL1

HAL2

GPIO_PinState HAL_GPIO_ReadPin(const GPIO_TypeDef *GPIOx,
                               uint16_t GPIO_Pin);
hal_gpio_pin_state_t HAL_GPIO_ReadPin(hal_gpio_t gpiox,
                                      uint32_t pin);
void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx,
                       uint16_t GPIO_Pin,
                       GPIO_PinState PinState);
void HAL_GPIO_WritePin(hal_gpio_t gpiox,
                       uint32_t pins,
                       hal_gpio_pin_state_t pin_state);
void HAL_GPIO_WriteMultipleStatePin(GPIO_TypeDef *GPIOx,
                                    uint16_t PinReset,
                                    uint16_t PinSet);
void HAL_GPIO_WriteMultipleStatePin(hal_gpio_t gpiox,
                                    uint32_t pins_reset,
                                    uint32_t pins_set);
void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
void HAL_GPIO_TogglePin(hal_gpio_t gpiox, uint32_t pins);
void HAL_GPIO_EnableHighSPeedLowVoltage(GPIO_TypeDef *GPIOx,
                                          uint16_t GPIO_Pin);
void HAL_GPIO_EnableHighSpeedLowVoltage(hal_gpio_t gpiox,
                                              uint32_t pins);
void HAL_GPIO_DisableHighSpeedLowVoltage(GPIO_TypeDef *GPIOx,
                                         uint16_t GPIO_Pin);
void HAL_GPIO_DisableHighSpeedLowVoltage(hal_gpio_t gpiox,
                                            uint32_t pins);
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx,
                                   uint16_t GPIO_Pin);
hal_status_t HAL_GPIO_LockPin(hal_gpio_t gpiox,
                              uint32_t pins);
void HAL_GPIO_ConfigPinAttributes(GPIO_TypeDef *GPIOx,
                                uint16_t GPIO_Pin,
                                uint32_t PinAttributes)
hal_status_t HAL_GPIO_SetSecAttr(hal_gpio_t gpiox,
                                 uint32_t pins,
                                 hal_gpio_sec_attr_t sec_attr);
HAL_StatusTypeDef HAL_GPIO_GetConfigPinAttributes(const GPIO_TypeDef *GPIOx,
                                                  uint16_t GPIO_Pin,
                                                  uint32_t *pPinAttributes);
hal_gpio_sec_attr_t HAL_GPIO_GetSecAttr(hal_gpio_t gpiox,
                                        uint32_t pin);

Note

In HAL1, the status of the pin security attribute is returned using a pointer parameter.

In HAL2, the status is returned directly by the function.

Related concept: HAL implementation with LL inline functions


HAL GPIO IRQHandler and callbacks operation functions

HAL1

HAL2

  • EXTI IRQHandler and callback functions are defined in HAL GPIO driver.

  • Select a specific pin connected to corresponding EXTI line.

  • All EXTI functions are removed from the HAL GPIO driver and replaced with exported functions in the HAL EXTI driver.

  • Select a specific line using hal_exti_handle_t structure.

  • New parameter added to the trigger callback function to select the EXTI trigger.

void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin);

void HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin);
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin);
void HAL_EXTI_IRQHandler(hal_exti_handle_t *hexti);

void HAL_EXTI_TriggerCallback(hal_exti_handle_t *hexti,
                              hal_exti_trigger_t trigger);

Related concept: Remove EXTI Intrinsic Management in System HAL Drivers; Let Users Rely on EXTI HAL Driver.